package hbase.HbaseStudy;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;

import java.io.IOException;

public class Hb03_insertData {
    private static String tableName = "sccc01:t3";
    // 添加数据不需要Admin
    public static void main(String[] args) throws IOException {
        Configuration conf = HBaseConfiguration.create();
        Connection HConn = ConnectionFactory.createConnection(conf);
        Table table = HConn.getTable(TableName.valueOf(tableName));

        // 插入数据 shell => put “表名”，“行建”，“列柱：列名”，“值”
        Put put = new Put("01".getBytes()); // put “表名”，“行建”
//        put.addColumn(列柱，列名，值)
        put.addColumn("info".getBytes(),"name".getBytes(),"Mary".getBytes());

        // 提交数据
        table.put(put);

        // 释放资源
        table.close();
        HConn.close();
    }
}
